package com.example.csetpp.controller;

import com.example.csetpp.constants.JWTConstant;
import com.example.csetpp.constants.WeChatConstant;
import com.example.csetpp.pojo.dto.PageDTO;
import com.example.csetpp.pojo.dto.PageUserDTO;
import com.example.csetpp.pojo.dto.RecordId;
import com.example.csetpp.pojo.dto.problem.ProblemDTO;
import com.example.csetpp.pojo.dto.problem.ProblemSearchDTO;
import com.example.csetpp.pojo.dto.problem.ResponseProblemDTO;
import com.example.csetpp.pojo.dto.user.*;
import com.example.csetpp.pojo.entity.Problem;
import com.example.csetpp.pojo.entity.User;
import com.example.csetpp.service.ProblemService;
import com.example.csetpp.service.UserService;
import com.example.csetpp.utils.JwtUtil;
import com.example.csetpp.utils.Result;
import com.example.csetpp.pojo.vo.UserLoginVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@Tag(name = "问题反馈相关")
@RequestMapping("/problem")
public class ProblemController {
    @Autowired
    private ProblemService problemService;

    @Operation(summary = "用户提交问题反馈")
    @PostMapping("/submit-question-feedback")
    public Result<?> submitQuestionFeedback(@RequestBody Problem problem) {
        problemService.submitQuestionFeedback(problem);
        return Result.success("OK");
    }

    @Operation(summary = "根据用户id分页查询历史反馈接口")
    @PostMapping("/get-user-feedback")
    public Result<?> getUserFeedback(@RequestBody PageUserDTO pageUserDTO) {
        return Result.success(problemService.getUserFeedback(pageUserDTO));
    }

    @Operation(summary = "分页获取未处理反馈")
    @PostMapping("/get-processed-feedback")
    public Result<?> getProcessedFeedback(@RequestBody ProblemSearchDTO problemSearchDTO) {
        return Result.success(problemService.getProcessedFeedback(problemSearchDTO));
    }

    @Operation(summary = "分页获取已处理反馈")
    @PostMapping("/get-unprocessed-feedback")
    public Result<?> getUnprocessedFeedback(@RequestBody ProblemSearchDTO problemSearchDTO) {
        return Result.success(problemService.getUnprocessedFeedback(problemSearchDTO));
    }


    @Operation(summary = "答复反馈接口")
    @PostMapping("/response-feedback")
    public Result<?> responseFeedback(@RequestBody ResponseProblemDTO responseProblemDTO) {
        problemService.responseFeedback(responseProblemDTO);
        return Result.success("OK");
    }

    @Operation(summary = "根据id删除反馈记录")
    @PostMapping("/delete-question-feedback")
    public Result<?> deleteQuestionFeedback(@RequestBody RecordId recordId) {
        problemService.deleteQuestionFeedback(recordId);
        return Result.success("OK");
    }

    @Operation(summary = "根据条件查询问题反馈")
    @PostMapping("/search-question-feedback")
    public Result<?> searchQuestionFeedback(@RequestBody ProblemSearchDTO problemSearchDTO) {

        return Result.success(problemService.searchQuestionFeedback(problemSearchDTO));
    }

}
